﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WuxiWTO.Mapping;
using WutiWTO.Common;
using System.Text;

namespace WuxiWTO.Web
{
    public partial class readComplain : System.Web.UI.Page
    {
        WTODataContext contex = new WTODataContext();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user_name"] == null && Request.Cookies["wtouser"] == null)
            {
                if (string.IsNullOrEmpty(Request.QueryString["ispub"]))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "paramerr", "parent.jQuery.fancybox.close();parent.location='login.aspx?ret=enterpriseComplain.aspx';", true);
                    return;
                }
            }
            if (!IsPostBack)
            {
                ReadContent();
            }
        }

        private void ReadContent()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["aid"]))
            {
                int comID = int.Parse(Request.QueryString["aid"]);
                Complaint com = contex.Complaints.SingleOrDefault(p => p.ID == comID);
                if (com != null)
                {
                    this.litQuestion.Text = com.question;
                    string status = "";
                    switch (com.record_status)
                    {
                        case 'N': status = "已提交"; break;
                        case 'R': status = "已受理"; break;
                        case 'P': status = "已处理"; break;
                    }
                    this.litStatus.Text = status;
                    this.litDateTime.Text = com.update_date == null ? "N/A" : com.update_date.ToString();
                    this.litFeedBack.Text = com.answer;
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "paramerr", "alert('参数传递失败');parent.jQuery.fancybox.close();", true);
            }

        }
    }
}